
#ifndef GAMEBOARD_H
#define GAMEBOARD_H

#include <QWidget>
#include <map>

class QPaintEvent;
class QMouseEvent;
class QPainter;
class QLabel;
class ChessPane;
class ChessBoard;
using std::map;

// 对ChessBoard的GUI封装
class GameBoard : public QWidget
{
    Q_OBJECT
public:
    GameBoard(QWidget * parent = 0);
    bool addPane(int x, int y);             // 依顺序一个一个下子

public slots:
    void restart(bool humenFirst = true);   // 重启
    void undo();                            // 悔棋

protected:
    virtual void mouseReleaseEvent(QMouseEvent*);   // 鼠标点击事件
    
private:
    typedef std::map<ChessPane*, QLabel*> Map;
    Map _maps;                              // 棋子与GUI上的图片的映射
    ChessBoard* _board;                     // chess库的棋局
    QLabel* latestPane[2];
    QLabel* background;
    int turn;                               // 轮次
};

#endif // CHESSBOARD_H
